/// <reference path="../../Scripts/jquery-1.7.1.js"/>

$(function() {
    archieJs.baseUrl = function() {
        return window.location.protocol + "//" + window.location.hostname + ":" + window.location.port;
    };

    function S4() {
        return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
    };

    archieJs.guid = function() {
        return (S4() + S4() + "-" + S4() + "-" + S4() + "-" + S4() + "-" + S4() + S4() + S4());
    };
    
    function _ajax_request(url, data, callback, type, method) {
        if (jQuery.isFunction(data)) {
            callback = data;
            data = {};
        }

        return jQuery.ajax({
            type: method,
            url: url,
            data: data,
            success: callback,
            dataType: type
        });
    };

    archieJs.put = function (url, data, callback, type) {
        return _ajax_request(url, data, callback, type, 'PUT');
    };
    
    archieJs.post = function (url, data, callback, type) {
        return _ajax_request(url, data, callback, type, 'POST');
    };

    archieJs.delete_ = function (url, data, callback, type) {
        return _ajax_request(url, data, callback, type, 'DELETE');
    };
});
